package com.wntime.simulator.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wntime.simulator.mapper.SimulationFieldMapper;
import com.wntime.simulator.domain.SimulationField;
import com.wntime.simulator.service.SimulationFieldService;

import java.util.Collections;
import java.util.List;

@Service
public class SimulationFieldServiceImpl extends ServiceImpl<SimulationFieldMapper, SimulationField> implements SimulationFieldService{

    @Override
    public List<SimulationField> getFieldsBySimulatorId(Long id) {
        QueryWrapper<SimulationField> wrapper = new QueryWrapper<>();
        wrapper.eq("simulator_id", id);
        List<SimulationField> fields = baseMapper.selectList(wrapper);
        if (fields == null || fields.isEmpty()) {
            return Collections.emptyList();
        }
        return fields;
    }
}
